<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数值分隔符</title>
</head>
<body>
    <h1>数值分隔符</h1>
    <h2>使用下划线(_)作为数字的分隔符</h2>

    <script>
        // 十进制数值
        const amount = 1_000_000_000;
        console.log(amount); // 1000000000

        // 二进制数值
        const binary = 0b1010_0001_1000_0101;
        console.log(binary); // 41349

        // 十六进制数值
        const hex = 0xA0_B0_C0;
        console.log(hex); // 10531008

        // 八进制数值
        const octal = 0o1234_5670;
        console.log(octal); // 2739128

        // 实际应用示例
        // 1. 金融数据
        const marketCap = 1_234_567_890.12;
        const bitcoinPrice = 50_000.00;
        const largeNumber = 1e10_000;

        // 2. 时间戳和日期
        const timestamp = 1_609_459_200_000; // 2021-01-01
        const secondsInYear = 365 * 24 * 60 * 60; // 31_536_000

        // 3. 配置常量
        const CONFIG = {
            MAX_CONNECTIONS: 100_000,
            TIMEOUT: 30_000,
            BUFFER_SIZE: 8_192,
            MAX_FILE_SIZE: 10_485_760 // 10MB
        };

        // 4. 位运算
        const PERMISSIONS = {
            READ: 0b0000_0100,
            WRITE: 0b0000_0010,
            EXECUTE: 0b0000_0001
        };

        // 5. 颜色值
        const colors = {
            RED: 0xFF_00_00,
            GREEN: 0x00_FF_00,
            BLUE: 0x00_00_FF
        };
    </script>
</body>
</html> 